Distributing limited storage among a collection of media objects

ABSTRACT

A quality level determining the extent to which each image file is compressed is automatically computed for each image file in a set to ensure that the total size of the compressed image files does not exceed a predefined limit. The compressed size of each image file is initially determined when compressed at a predefined minimum acceptable level and at a nominal level. The relative complexity of the image files is determined based upon their high frequency energy content. As a function of the image file complexity, and starting with the compressed sizes initially determined, the appropriate quality level is determined for compressing each of the image files in an iterative process that ensures the total size of the compressed image files does not exceed the predefined limit, while retaining acceptable quality. Thus, a set of image files can be compressed optimally to fit within a limited storage.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.11/149,037, filed on Jun. 8, 2005, entitled “DISTRIBUTING LIMITEDSTORAGE AMONG A COLLECTION OF MEDIA OBJECTS”, which is a continuation ofU.S. patent application Ser. No. 10/099,807, filed on Mar. 14, 2002,entitled “DISTRIBUTING LIMITED STORAGE AMONG A COLLECTION OF MEDIAOBJECTS”, which issued as U.S. Pat. No. 6,976,026 on Dec. 13, 2005. Theentireties of the aforementioned applications are incorporated herein byreference.

FIELD OF THE INVENTION

This invention generally pertains to controlling the size of a pluralityof data files 5 that must fit in a limited storage, and morespecifically, for selecting a quality parameter that determines the sizeof each data file so that the total size of the plurality of data filesis no greater than a predetermined limit.

BACKGROUND OF THE INVENTION

There are many occasions when it is necessary to copy a collection ofimage files 10 onto a floppy disk or send a collection of image files asan attachment to an email message. However, given the transmission timeand permissible email attachment size, it may be necessary to limit thetotal size of the attachment. Similarly, if the file size (in bytes) ofeach of the original image files in the collection is relatively large,it will often not be possible to fit all of the images in the collectiononto a conventional 1.44 MB floppy disk, particularly, since other filesmay be stored on the floppy disk using some of the available storage.Typically, a person might decide to address these limitations byreducing the number of images that are saved onto a floppy or that willbe sent as the email attachment so that the total bytes of the imagefiles will be equal or less than the available storage size on the disk,or sufficiently small to be acceptable as an attachment 20 to an emailmessage.

Another approach that is often employed in addressing this problem is tosave each of the images in a compressed file format so that the totalsize (in bytes) of the compressed images in the collection will fit inthe available storage on the floppy disk or be sufficiently small totransmit as an email attachment. While there are other compressionstandards, one of the more popular compression formats for saving imagesemploys the Joint Photographic Experts Group (JPEG) standard. The filesizes of images compressed using the JPEG standard can be substantiallysmaller than that of the original decompressed images, but there is aslight disadvantage in using this compression scheme. The JPEG standardemploys a “lossy” type of compression, so there is always a loss of someof the data that was in the original decompressed image when thecompression scheme is applied and the compressed file is subsequentlydecompressed for viewing. The lost data cannot be recovered from thecompressed image.

The amount of image data that is lost and thus, the quality of the imagethat is displayable after decompressing the compressed image data isdetermined by a quality level. The quality level determines the amountof compression applied to the original data in producing the compresseddata file. Theoretically, the quality level can range between a minimumquality level of “0” and a maximum quality level of “100,” where ahigher quality decompressed image is achieved by reducing the amount ofcompression that is applied to the image file. However, as a practicalmatter, it is generally agreed by those skilled in the art that anacceptable compression range can be obtained using a quality levelbetween 5 and 95. If a quality level below 5 is used to compress animage, the appearance of the image after it is subsequently decompressedwill often be of too low quality to be usable, while if the qualitylevel is set above 95, the amount of compression (or file sizereduction) that is achieved will be too little to justify the use of thecompression scheme.

Images can differ substantially in regard to their complexity. An imagethat consists mostly of large areas having minimal color and contrastvariation is much less complex than an image with lots of detail andvariation in color and contrast. For example, an image of a uniformcolor, cloudless sky is much less complex than an image of a maple treecovered with thousands of brightly colored autumn leaves. An image withless complexity can be compressed to a much larger extent than an imageof greater complexity, while retaining about the same perceived qualityafter being decompressed.

Typically, to fit a group of compressed files into a specified storage,the same quality level will be used in compressing each of the imagefiles in the group. However, the results will often be disappointing,since more complex images will lose too much detail and appearunacceptable when subsequently decompressed and displayed. Less compleximages will typically be compressed less than they might be and stillretain an acceptable quality when decompressed. It would therefore bepreferable to employ a higher quality level when compressing images thatare more complex and a lower quality level when compressing images thatare of lower complexity. Yet, the size of a compressed image file willnot be evident until the compression scheme has actually been applied.Consequently, it will be unduly burdensome to manually test differentquality levels for use in compressing each image in a collections toarrive at a mix different optimal quality levels that should be appliedto ensure that all of the compressed image files in the set will fit ona floppy disk, or be sufficiently small to send as an email attachment.Clearly, it would be desirable to provide a program that canautomatically determine an acceptable near optimal quality level thatshould be used in compressing each image file in a set, so that thetotal size of the resulting compressed image files is within somespecified limit. The program should determine the quality level andthus, the corresponding degree of compression applied to each image inthe set, based upon the complexity of the images.

SUMMARY OF THE INVENTION

The present invention is directed to a method for automaticallydetermining the compression level that will be applied in compressingfiles to fit within a limited storage or so that the total compressedfile size is less than a predefined limit. While not limited tocompressing image files, the method is thus applicable in determininghow to most effectively compress a set of image files to fit within anavailable storage capacity of a medium such as a floppy disk. In thismethod, a quality level is automatically determined for compressing eachfile to produce a compressed file, so that a total size of thecompressed files does not exceed the predefined limit.

This method can perhaps be most readily understood in connection withcompressing a set of image files. Initially, each image file in the setis processed to determine a compressed file size when compressed to apredefined minimum quality level. In this regard, it should be notedthat the greater the degree of compression, the lower the quality of theimage that can be displayed when the compressed file is decompressed.Ideally, the compression that is applied to each file should be selectedbased upon the complexity of the file, while ensuring that the totalsize of the compressed files does not exceed the predefined limit.Initially, a nominal compressed file size is also determined for eachfile when compressed to a nominal quality level. In addition, a weightis determined for each image file based upon a high frequency energycontent of the image file, which is related to the complexity of theimage file. An image file that is more complex will have a greater highfrequency energy content and thus, a greater weight than a relativelysimple image file. Image files that are suitable to be compressed withthe predefined minimum acceptable quality level are then identified as afunction of the compressed file size of the image files when compressedto the predefined minimum acceptable quality level and as a function ofthe weight of the image files.

For the other image files of the set that will not be compressed withthe predefined minimum quality level, it is necessary to determine anoptimal quality level for use in compressing the files. The appropriatequality level is determined so that each of these other image files willbe compressed to a desired size that is selected as a function of theweight of the image file, but so that the total size of all of thecompressed image files will not exceed the predefined limit. The imagesfiles identified as suitable to be compressed to the predefined minimumacceptable quality and the other image files that are to be compressedwith the quality levels that were determined for each of them are thencompressed at these respective quality levels.

For a given type of compression, there is typically a preferable rangeof quality levels that should be used. If JPEG compression is employed,the range of quality levels that is generally considered acceptable isfrom about 5 to about 95, on a scale ranging from 0 through 100. It isthus preferable to limit the quality level that is used in compressingthe image files to a predetermined range that extends from thepredefined minimum acceptable quality level, e.g., 5, to a substantiallyhigher maximum acceptable quality level, such as 95.

A scaling factor is also determined based upon the space remaining forcompressed files relative to the predefined limit, and upon a totalweight of all of the image files not being compressed to the predefinedminimum acceptable quality level. Indeed, the step of identifying imagefiles that will be compressed with the predefined minimum acceptablequality level is repeated in successive passes through the set of imagesfiles, until a pass through the image files is completed withoutidentifying any additional image file to be compressed at the predefinedminimum acceptable quality level.

To determine the quality level that will be used,for compressing theother image files, a desired size of the compressed image file iscomputed for each file. The desired size is preferably determined as afunction of the weight of the image file. The method then calls fordetermining an optimal quality level to apply to each image file toachieve the desired size when the image file is compressed. Thedifference between the desired size and an actual size of the image filewhen it is compressed to the optimal quality level is also computed.

In determining the optimal quality level, the method starts with thenominal quality level and determines if the nominal compressed file sizeis less than the desired size by no more than a predefined difference,and if so, assigns the nominal quality level as the optimal qualitylevel. If not, the method reduces the range from which a new qualitylevel to try is selected. The new quality level that is selected in thisnarrower range is determined using a model that relates the imagequality to the compressed file size. If the compressed file sizeresulting from compressing the image file using the new quality level isless than the desired size by no more than the predefined difference,the new quality level is assigned as the optimal quality level. If not,the preceding two steps are repeated with successive new quality levels,until the optimal quality level is determined.

Another aspect of the present invention is directed to a memory mediumon which are stored machine instructions for carrying out the steps ofthe method. Yet another aspect is directed to a system that includes amemory in which machine instructions are stored, and a processor thatexecutes the machine instructions, causing the processor to carry outfunctions that are generally consistent with the steps of the methoddescribed above.

BRIEF DESCRIPTION OF THE DRAWING FIGURES

The foregoing aspects and many of the attendant advantages of thisinvention will become more readily appreciated as the same becomesbetter understood by reference to the following detailed description,when taken in conjunction with the accompanying drawings, wherein:

FIG. 1 is a functional block diagram of a generally conventionalpersonal computer that is suitable for use in implementing the presentinvention;

FIG. 2 is a high level flow chart showing the main steps implemented inpracticing the present invention when determining a quality level to beapplied in compressing each of a set of image files so that theresulting compressed files will fit within an available storage space;

FIG. 3 is a more detailed flow chart showing the steps employed in theinitial processing of image files;

FIG. 4 is a detailed flow chart showing the steps used to identify theimage files that will be compressed with the minimum quality level(i.e., to achieve a maximum acceptable compression);

FIG. 5 is a flow chart showing the steps applied in determining thequality level applied to all of the other image files (i.e., those notto be compressed to the minimum quality level); and

FIGS. 6A, 6B, and 6C together illustrate a flow chart showing thedetailed steps applied in determining an optimal quality level for eachimage that is not to be compressed to the minimum quality level.

DESCRIPTION OF THE PREFERRED EMBODIMENT Computing Environment forImplementing the Present Invention

FIG. 1 and the following discussion related thereto are intended toprovide a brief, general description of a suitable computing environmentin which the present invention may be implemented. This invention ispreferably practiced using one or more computing devices. If multiplecomputing devices are employed, they may be coupled to each other by acommunications network, and one of the computing devices may bedesignated as a client and the other as a server. For example, theserver may include storage on which are stored the image files to becompressed. Both the server and the client computing devices willtypically include the functional components shown in FIG. 1. Althoughnot required, the present invention is described as employing computerexecutable instructions, such as program modules that are executed by aprocessing device. Generally, program modules include applicationprograms, routines, objects, components, functions, data structures,etc. that perform particular tasks or implement particular abstract datatypes. Also, those skilled in the art will appreciate that thisinvention may be practiced with other computer system configurations,including handheld devices, pocket personal computing devices, digitalcell phones adapted to execute application programs and to wirelesslyconnect to a network, other microprocessor-based or programmableconsumer electronic devices, multiprocessor systems, network personalcomputers, minicomputers, mainframe computers, and the like. Asindicated, the present invention may also be practiced in distributedcomputing environments, where tasks are performed by one or more serversin communication with remote processing devices that are linked througha communications network. In a distributed computing environment,program modules may be located in both local and remote memory storagedevices.

With reference to FIG. 1, an exemplary system for implementing thepresent invention includes a general purpose computing device in theform of a personal computer 20 that is provided with a processing unit21, a system memory 22, and a system bus 23. The system bus couplesvarious system components, including the system memory, to processingunit 21 and may be any of several types of bus structures, including amemory bus or memory controller, a peripheral bus, and a local bus usingany of a variety of bus architectures. The system memory includes readonly memory (ROM) 24 and random access memory (RAM) 25. A basicinput/output system (BIOS) 26 containing the basic routines that areemployed to transfer information between elements within computer 20,such as during start up, is stored in ROM 24. Personal computer 20further includes a hard disk drive 27 for reading from and writing to ahard disk (not shown), a magnetic disk drive 28 for reading from orwriting to a removable magnetic disk 29, and an optical disk drive 30for reading from or writing to a removable optical disk 31, such as aCD-ROM or other optical media. Hard disk drive 27, magnetic disk drive28, and optical disk drive 30 are connected to system bus 23 by a harddisk drive interface 32, a magnetic disk drive interface 33, and anoptical disk drive interface 34, respectively. The drives and theirassociated computer readable media provide nonvolatile storage ofcomputer readable machine instructions, data structures, programmodules, the image files, and other data for personal computer 20.Although the exemplary environment described herein employs a hard disk,removable magnetic disk 29, and removable optical disk 31, it will beappreciated by those skilled in the art that other types of computerreadable media, which can store the images files and other data that areaccessible by a computer, such as magnetic cassettes, flash memorycards, digital video disks (DVDs), Bernoulli cartridges, RAMs, ROMs, andthe like, may also be used in the exemplary operating environment.

A number of program modules may be stored on the hard disk, magneticdisk 29, optical disk 31, or in ROM 24 or RAM 25, including an operatingsystem 35, one or more application programs 36, other program modules37, and program data 38. A user may enter commands and information intopersonal computer 20 through input devices such as a keyboard 40,graphics pad, and a pointing device 42. Other input devices (not shown)may include a microphone, joystick, game pad, satellite dish, scanner,or the like. These and other input/output (I/O) devices are oftenconnected to processing unit 21 through an I/O interface 46 that iscoupled to system bus 23. The term I/O interface is intended toencompass interfaces specifically used for a serial port, a parallelport, a game port, a keyboard port, and/or a universal serial bus (USB),and other types of data ports. A monitor 47, or other type of displaydevice, is also connected to system bus 23 via an appropriate interface,such as a video adapter 48, and is usable to display applicationprograms, Web pages, the original and decompressed image files, and/orother information. In addition to the monitor, the server may be coupledto other peripheral output devices (not shown), such as speakers(through a sound card or other audio interface, not separately shown),and printers.

As indicated above, the present invention can readily be practiced on asingle computing device; however, personal computer 20 might alsooperate in a networked environment using logical connections to one ormore remote computers, such as a remote computer 49, which may be aclient computer exchanging data over the network. Remote computer 49 mayalternatively be a server, a router, a network PC, a peer device, or asatellite or other common network node, and typically includes many orall of the elements described above in connection with personal computer20, although only an external memory storage device 50 has beenillustrated in FIG. 1. The logical connections depicted in FIG. 1include a local area network (LAN) 51 and a wide area network (WAN) 52.Such networking environments are common in offices, enterprise widecomputer networks, intranets, and the Internet.

When used in a LAN networking environment, personal computer 20 isconnected to LAN 51 through a network interface or adapter 53. When usedin a WAN networking environment, personal computer 20 typically includesa modem 54, or other means such as a cable modem, Digital SubscriberLine (DSL) interface, or an Integrated Service Digital Network (ISDN)interface, for establishing communications over WAN 52, which may be aprivate network or the Internet. Modem 54, which may be internal orexternal, is connected to the system bus 23 or coupled to the bus viaI/O device interface 46; i.e., through a serial port. In a networkedenvironment, image files, data, and program modules depicted relative topersonal computer 20, or portions thereof, may be stored in the remotememory storage device. It will be appreciated that the networkconnections shown are exemplary and other means of establishing acommunications link between the computers may be used, such as wirelesscommunication and wideband network links.

Exemplary Application of the Present Invention

While it again should be emphasized that the present invention is not inanyway limited to compressing image files to fit within the availablestorage space on a floppy disk or other storage medium, the presentinvention was specifically developed for such an application. Clearly,however, the ability to automatically select a compression quality orcompression size for files to meet some specified limit is applicable toother applications. For example, it will be useful for compressing imagefiles in a set to a compressed size that is acceptable for use in anattachment to an email message. The present invention will enable a userto efficiently compress the image files, while maintaining an acceptablequality of the image files when decompressed. Thus, the attachmentcomprising the set of compressed image files can be made sufficientlysmall in size to ensure that the email and attachment are efficientlytransmitted to a recipient over a relatively slow network connection.

The only requirement for use of the present invention is that a file becompressible using a lossy compression scheme in which a parameter suchas a compression quality level is used to set the degree of compression.Since an initial application of the present invention was for use inselecting the degree of compression of a set of image files so that oncecompressed, the compressed image files would all fit within theavailable storage of a floppy disk, a preferred embodiment forimplementing that application is disclosed below.

With reference to FIG. 2, a flow chart 100 illustrates the broad stepsthat are carried out in practicing the present invention. Beginning witha block 102, a determination is made of the available space in which thecompressed image files will be stored. Alternatively, this step might bedirected to determining a desired total size for all of the compressedfiles in the set, or some other desired limit on the total size of thecompressed files. Other files besides the compressed image files willlikely be stored on a floppy disk, so that the available capacity of thefloppy disk for storing these compressed files will be less than theoriginal 1.44 MB. However, it is equally possible that the image filesmight be stored on either a larger storage medium. In this exemplarypreferred embodiment, it is generally assumed that less than all of thestorage of a floppy disk is available for storing up to 40 compressedimage files, so that the image files can subsequently be read from thefloppy disk when it is inserted into an appropriate floppy drive. Forexample, in the proposed application, the floppy drive is included in animage viewing product that is coupled to a standard television fordisplay of the image files on the television screen after the compressedfiles on the floppy disk are decompressed. To implement thisapplication, it is necessary to store other files on the floppy disk. Itis also possible that the floppy disk or other storage medium mightsimply be used for storing the compressed image files until such timethat the user chooses to display them on the PC monitor or otherdisplay. To display the compressed image files, they must first bedecompressed.

Alternatively, the image files might be compressed for inclusion as anattachment to an email message, in which case the total desired size ofthe compressed files (and the number of image files in the set beingcompressed) may be smaller. Block 102 simply indicates that theparameter specifying the total size of the compressed images files mustinitially be known or determined.

In a block 104, initial processing of the image files in the set iscarried out. Details of the steps implemented for this and each of theother blocks shown in FIG. 2 are discussed below. A block 106 determinesthe images that will be compressed to the lowest quality level (maximumacceptable extent of compression). It is generally known by those ofordinary skill in the art that for a particular type of lossycompression, such as the JPEG system, there is an acceptable ordesirable range of image quality level that is applicable to compressingimages so that the images, when subsequently viewed on a display afterbeing decompressed, retain an acceptable level of quality. As discussedabove, the quality of an image is likely to be more adversely affectedwhen compressed at a given quality level, if the image is more complexthan if the image is relatively low in complexity, with little detail.One measure of complexity or detail in an image is its high frequencyenergy. Images that have little high frequency energy and are thus oflow complexity can readily be compressed at a predefined minimumacceptable quality level (i.e., using the greatest acceptablecompression) within the acceptable range, without experiencing anunacceptable loss of detail when decompressed for viewing. Thus, thesteps carried out in block 106 simply identify those images that can becompressed to this predefined lowest acceptable quality level andmaximum compression.

If JPEG compression is used, as is true in this preferred embodiment, itis generally agreed that an acceptable range of the quality level thatmight be used for compressing image files is between about 5 and about95 (on a scale from 0 to 100). As a result, the steps carried out inblock 106 identify those image files that can be compressed using theJPEG compression scheme at a quality level of 5. However, it will beunderstood that a different minimum acceptable quality level and adifferent range of quality level can instead be employed in the presentinvention, depending upon the preferences of a user and the type ofcompression scheme employed to compress the image files.

A block 108 provides for determining the compression level that shouldbe applied to all of the other image files to ensure that the totalstorage required for the compressed image files of the set does notexceed the available space determined in block 102. Clearly, in thisblock, it is preferable to determine the optimal quality level to applyin compressing the other image files within the range from thepredefined minimum acceptable quality level to the highest quality levelwithin the range noted above. Finally, in a block 110, all of the imagefiles are compressed at the quality level that was determined, includingthe image files that were identified as suitable to be compressed at thepredefined minimum acceptable quality level, and those for which aspecific quality level was determined in block 108. The result is a setof compressed image files that are no greater than the available storagespace or predefined limit for the total size of the compressed filesthat was determined in block 102.

Turning to FIG. 3, details of the steps implemented in block 104 areillustrated. Beginning with a decision step 112, the method determinesif any more image files remain to be processed, since this procedureloops through all of the image files in the set. If so, a step 114provides for processing the next image file in the set. Thereafter, in astep 116, the initial processing steps are applied to the current imagefile from the set. In step 116, a variable referred to ascompressionlevel is initialized to “unknown.” Next, the minimum size ofthe current image file, which is identified by the variable minsize isset equal to the compressed size of the current image file whencompressed at the predefined minimum quality level (e.g., a JPEG qualitylevel of 5). Within the acceptable range, a nominal quality level is 70.Accordingly, a variable initsize is set equal to the size of thecompressed image file resulting from compressing the current image fileat a quality level of 70. Finally, a variable weight is computed for thecurrent image file, based upon the following equation:

${weight} = {\lbrack {\frac{DCT\_ hfEnergy}{50*{DCT\_ nblocks}}*( {{{nPixels}*3\; E} - 6} )^{1.3}} \rbrack^{0.28}*( {{{nPixels}*3\; E} - 6} )}$

The above equation used for computing weight for an image file as afunction of the high frequency energy (DCT_hfEnergy) of the image wasempirically determined. The high frequency energy is indicative of thecomplexity of the image and is a characteristic of a particular imagethat is indicative of how much compression can be applied withoutincurring an unacceptable loss of detail. The equation shown above isjust one exemplary choice and was designed to increase the weight of animage file as its high frequency energy content increases and as anonlinear function of the number of pixels (nPixels) in the image.Clearly, image files with more pixels (i.e., higher resolution) willrequire more bytes to be included in the compressed file to achieve thesame quality when decompressed, compared to an image file having fewerpixels. One interesting aspect of the present invention is therealization that these two relationships must be nonlinear for aconstant perceived image quality to be achieved for different compressedimage files when subsequently decompressed and displayed.

The above equation is better suited to images having equal numbers ofpixels, but nevertheless, enables image files to be of different sizeprior to compression. In the above equation, the term DCT_hfEnergyrefers to information pertaining to the high frequency energy contentthat is gathered during a discrete cosine transform, which is carriedout as part of the JPEG compression algorithm applied to each imagefile. Similarly, DCT_nblocks is information relating to the number ofblocks, which is also determined during the discrete cosine transform.

In a preferred embodiment, the high-frequency energy is computed by thefollowing equation:

${DCT\_ hfEnergy} = {\sum\limits_{{block} = 1}^{DCT\_ nblocks}\; \sqrt{\sum\limits_{i = {N\; 1}}^{N\; 2}\; {\sum\limits_{j = {N\; 1}}^{N\; 2}\; {{{DCT}_{block}( {i,j} )}}^{2}}}}$

In the above equation, the parameters N1 and N2 determine the range ofDCT frequencies whose energies should be accounted for. DC componentsshould not be included in this computation, and thus N1>0. In a typicalimplementation, N1=4 and N2=7. The square root operator computes aroot-mean-squared (RMS) energy for each block, and thus, the final valueof DCT_hfEnergy is the average of the RMS block energies.

Next, the steps that are implemented to identify any image files thatwill be compressed to the predefined minimum acceptable quality level inthe selected range are illustrated in FIG. 4. This process begins with astep 120 in which a variable weightsum is initialized to zero. Adecision step 122 determines if there are any more images to beprocessed. If so, in a step 124, the next image file in the set isevaluated. A decision block 126 determines if the variableimage.compression level is currently “unknown,” which will be true forevery image file in the initial pass through the procedure illustratedfor block 106. If so, in a step 128, the variable weightsum isincremented to include the value of weight for the current image. Thisstep eventually returns a final value for weightsum that is equal to thetotal weight of all of the images in the set. After each image isevaluated, the logic returns to decision step 122 until no furtherimages are available to be processed. The logic then proceeds to a step130.

In step 130, a variable factor is set equal to the quotient resultingfrom dividing the value of the variable availablespace, which is thetotal space available for storing images, by the last calculated orrunning value for the total weight of the images (weightsum). Inaddition, a variable identified as needtocheck is set equal to theBoolean value, false. The image files are then again scanned, leading toa decision step 132, which determines if there are any more images to beprocessed in the current pass through the image files. If so, a step 134provides for evaluating the next image file. A decision step 136 thendetermines if a variable image.compression level for the current imagefile being evaluated is “unknown,” and if so, proceeds to a decisionstep 138, which determines if the compressed file size of the currentimage when compressed at the minimum quality level (a variableimage.minsize) is greater than or equal to the product of the weight ofthe current image and the factor variable. If so, the current image isidentified as being one that should be compressed to the predefinedminimum quality level, i.e., the variable image.compressionlevel is setequal to minlevel. Accordingly, a step 140 sets the compressed level forthe current image equal to the predefined minimum quality level. Inaddition, the compressed file size for the current image is set equal tothe size of the compressed image file for the current image when it iscompressed to the predefined minimum quality level. The availablespacevariable is then decremented by the compressed size of the image file(by the value of the variable imaged.compressedsize) when thuscompressed to the predefined minimum quality level. Finally, thevariable needtocheck is set equal to the Boolean value true.

The significance of setting the needtocheck variable equal to true is toindicate that during the current pass through the set of image files, atleast one image file was identified as suitable to be compressed to thepredefined minimum quality level. Thereafter, the logic loops back todecision step 132, which determines if there are any more image files toprocess. Once each of the image files in the set has been processed, theresult from decision step 132 leads to a decision step 142. In thisdecision step, the value of the variable needtocheck is determined. Ifits Boolean value is equal to false, the last pass through all of theimage files failed to identify any further image file that should becompressed to the predefined minimum quality level and step 106 of theoverall procedure is completed. However, if the value of the needtocheckvariable is true, the logic loops back to step 120, which againinitializes the variable weightsum equal to zero. Again, the logicproceeds to decision step 122, looping through step 124, decision step126, and for those image files that have not been identified as beingcompressed to the predefined minimum quality level, continuing to step128, which increments the value of weightsum with the weight of thecurrent image file (which is not to be compressed to the predefinedminimum quality level).

Once all of the image files have been processed, the logic proceeds tostep 130, with a value for weightsum now equal to the total weight ofall of the image files that have not yet been identified as beingcompressed to the predefined minimum quality level. The logic againproceeds through decision step 132, starting another pass through theset of image files and evaluating each of the image files not yetidentified as being suitable to compress to the predefined minimumquality level, with the logic of decision step 138. However, in decisionstep 138, since the value of factor will be different in the currentpass, it is possible that one or more additional image files will beidentified as suitable to compress to the predefined minimum qualitylevel. Thus, the steps implemented in FIG. 4 are reiterated until nofurther image files is identified to be compressed to the minimumquality level within a current pass through the set of image files, asdetermined in decision step 142.

In FIG. 5, details of block 108 are illustrated. In a step 150, avariable identified as unusedbytes is initialized to zero. A decisionstep 152 determines if any more image files remain to be processed andif so, the logic proceeds to a step 154 to enable processing of the nextimage file. A decision step 156 determines whether the compression level(or quality level) for the current image file being processed is stillunknown. If so, which will initially be true of all of the remainingimage files that are not identified as suitable for compression at thepredefined minimum quality level, the procedure continues with a step158. In this step, a variable desiredsize is set equal to the sum of thevariable unusedbytes and the product of the weight of the current imageand the variable factor. It will be recalled, that factor was determinedon the last pass through the image files in the logical stepsillustrated in FIG. 4, at step 106. Accordingly, the value of factorcorresponds to that related to the last determination of available spaceand the last computed total of all of the weights of the image files notpreviously identified as being suitable for compression to thepredefined minimum quality level. The variable desiredsize is thusdetermined for each image file that is not to be compressed to thepredefined minimum quality level.

A block 160 provides for computing the optimal compression quality foreach such image file. Unlike any image file that is to be compressed tothe predefined minimum quality level, each of the remaining image fileswill preferably be compressed to a quality level that most closelyachieves the desiredsize so that the total required storage for all thecompressed image files does not exceed the capacity of the availablestorage or other predefined limit. Thus, block 160 involves asubstantial number of steps, which are disclosed below in connectionwith FIGS. 6A, 6B, and 6C. After the optimal compression quality levelis determined for the current image file, the logic proceeds to a step162 which determines a value for the variable unusedbytes as equal tothe difference between the value of desiredsize and the actualcompressed size of the image (image.compressedsize) when compressed tothe optimal compression quality level determined in the proceeding step.Thus, the variable unusedbytes corresponds to the leftover storage fromthe current image file that was processed in block 160, since a specificoptimal quality level will often result in a compressed file size thatis slightly less than the value of desiredsize. Thereafter, the logicloops back to decision step 152 to determine if any more image filesneed to be processed. If not, the logic is done, enabling the procedureto return to block 110, in FIG. 2.

As an alternative to employing the space remaining after determining theoptimal compression quality for the previous image file in determiningthe desired size for the next image file (step 158), it is alsocontemplated that the value of the variable unsuedbytes could beaccumulated over all of the image files, and then distributed among theimage files that were compressed to a size less than the desired size bysome predefined limit. For example, the unused space could bedistributed to the image files that were compressed to a size that wascloser to 90% of the desired size than to those that were compressed toa size that was closer to 100% of the desired size. This pass would thenadjust the optimal quality level a little higher for the image filesthat were initially compressed more than desired.

As noted above, the procedure followed to determine the optimal qualitylevel used in compressing image files in this exemplary application ofthe present invention is somewhat complex. The logical steps employedare shown in three flow chart sections 158 a, 158 b, and 158 c, whichare shown in FIGS. 6A, 6B, and 6C, respectively. Tags identified “A”,“B”, and “C” in these three Figures indicate the point of logicalconnection between the steps illustrated in the Figures. One or morepasses are made for each image file that is processed, to determine itsoptimal quality level. A first pass is made through the steps in FIG.6A. It the first pass does not identify the optimal quality level, theimage file is processed according to the steps of FIG. 6B. If necessary,remaining passes are carried out in accord with the logic of FIG. 6C todetermine the optimal quality level for the image file.

Referring first to FIG. 6A, a step 170 provides for initializing severalvariables used in the procedure. Specifically, a variable size is setequal to the variable image.initsize, which is the size of the currentimage file when compressed at the nominal quality level (e.g., a qualitylevel equal to 70), for those image files that are not identified assuitable to be compressed to the predefined minimum quality level. Itshould be noted that the procedure shown in FIGS. 6A, 6B, and 6C iscarried out for a current image file to determine the optimalcompression quality level that will be applied to it when it iscompressed. Thus, the steps shown in these three figures are applied toeach of the image files that have not been identified as suitable to becompressed at the predefined minimum quality level. In step 170, avariable lowlevel is set equal to the predefined minimum acceptablequality level (represented by the variable minlevel) minus one. As notedabove, if JPEG compression is used, this preferred embodiment uses aquality level 5 as the predefined minimum quality level, so that thevariable lowlevel would be set equal to 4. Similarly, a variablehighlevel is set equal to the maximum quality level (represented by thevariable maxlevel) plus one so that for JPEG compression and using theaccepted range that extends from 5 to 95, the value of highlevel wouldbe equal to 96. A minsize variable is set equal to the product of thevariable desiredsize and 0.90, where the value of the variabledesiredsize was previously calculated as noted above. Variables Q and Q0are both set equal to 70, corresponding to the nominal quality level, avariable S0 is set equal to size to provide temporary storage for thevariable size, and a variable OLD_G is set equal to 0.0.

A decision step 172 provides for determining if the variable size isless than the variable minsize (which at this point is equal tonine-tenths of the value of the variable desiredsize). If so, the sizeof the current image file is not within ten percent of the value of thevariable desiredsize. However, if the result from decision step 172 isnegative, a decision step 174 determines if the variable size is greaterthan the value of desiredsize. If not, the actual size of the compressedfile when compressed to the nominal quality level is within ten percentof the desiredsize and as a result, in a step 176, theimage.compressionlevel or quality level is set equal to the currentlevel of Q, which is 70. Similarly, the image.compressedsize is equal tothe current value of size, which is the size of the drawing file whencompressed to the nominal quality level 70. At this point, the optimalquality level is determined for the current image file and the procedureis complete, causing the logic to return to step 162 in FIG. 5.

If the response to decision step 172 in FIG. 6A is positive, a step 178provides for setting a variable lowlevel equal to the value Q (currentlyequal to quality level 70). Similarly, if the results in decision step174 are affirmative, a variable highlevel is set equal to the variable Q(currently equal to a quality level of 70) in a step 180. Followingeither step 178 or 180 the logic proceeds to a step 182 in FIG. 6B.

The purpose of the loops shown in FIGS. 6B and 6C is to reiterativelyadjust the quality level applied in compressing the image files untilthe optimal quality level is determined. To accomplish this goal, thevariable Q is adjusted up or down according to the results of theprevious pass through the logic in these two FIGS. 6A and 6B), toproduce a compressed file size that is neither too large (i.e., greaterthan the value of desiredsize), nor too small (less than 90% ofdesiredsize). Before Q is adjusted on a subsequent pass through theseloops, an interval ranging between the variable lowlevel and thevariable highlevel is reduced to minimize the number of iterationsrequired to determine the optimal quality level. The iterative processis terminated when either the size of the compressed file achieved witha current quality level is outside the desired range defined by thevariables minsize and maxsize, and the quality level Q is outside theinterval between lowlevel and highlevel, OR, when the interval definedby lowlevel and highlevel shrinks to a step of only one, since at thatpoint there is no need to continue to adjust the quality level, becausethe size will then be as close to the desiredsize as can be achieved.

In step 182, a first value for the quality level Q is computed based onits first value determined in step 176, the first compressed size, andthe desiredsize. The computation is specified by the followingequations:

A=log₁₀(size)−s mod(0, Q/100)

Q=q mod i(A, log₁₀(desiredsize))

where the nonlinear functions smod( ) and qmodi( ) are defined by:

s mod(a,q)≡a+b(e ^((q−0.5)) ³ ^(+c(q−0.5))−1)

and where b and c are parameters typically set as b=4.2 and c=0.1, andfurther where:

q mod i(a,s)=0.5+root3(c, −log₁₀(1+|s−a|/b))

In the preceding equation, the parameters b and c are the same asbefore, and the function root3(q,r) returns a solution x to the equationx³+qx−r=0. The purpose of the equations above is to provide a firstestimate of the quality level Q that should be used to achieve thedesired compressed file size. The nonlinear functions were derived fromfitting nonlinear models to size versus quality curves for a database ofimages.

The variable Q is then again defined as a function of the maximum of thesum of lowlevel plus one and (the minimum of highlevel minus one and Qtimes 0.97). The variable size is then redefined as the compressed sizeof the image when compressed to the quality level Q that was justdetermined (referenced by the variable compressedsize(image, Q). Avariable Q1 is set equal to the current value for the quality level Q,and a variable S1 is set equal to the current value of size determinedabove in step 182.

A decision step 184 determines if the current value of size is less thanthe variable minsize and if not, a decision step 186 determines if thecurrent value of size is greater than the desiredsize for the imagefile. If not, a step 188 sets the compression level for the currentimage (image.compressionlevel) equal to the current value for thequality level Q, and sets the variable image.compressedsize equal to thecurrent value of the variable size. At this point, the optimal qualitylevel for compressing the current image file is determined and the logicagain would return to next step in FIG. 5, i.e., to step 162.

If the result in decision step 184 is affirmative, indicating that thecurrent value of size is less than the variable minsize, the logicproceeds to a step 190, which sets the variable lowlevel equal to thecurrent quality level, Q. Similarly, if the result in decision step 186indicates that the current value of the variable size is greater thanthe desiredsize, a step 192 sets the variable highlevel equal to thecurrent quality level, Q. After either step 190 or 192, the logicproceeds via connector B to a step 194 in FIG. 6C.

Referring to FIG. 6C, step 194 defines a new value for the qualitylevel. Initially in step 194, a variable G is defined as a function ofthe variables S1, S0, and Q0. If G is found to be identical to zero, Gis redefined as one-fourth the variable, OLD_G. Next, the variable OLD_Gis set equal to the value of the variable G. Q is then redefined as thesum of Q1 and the quotient of the difference between desiredsize and S1when divided by the variable Q. An IF clause provides that if this passis the first through step 194 and if Q is greater than or equal to 95(the maximum acceptable quality level), then Q is redefined as beingequal to the product of 0.98 and 95. Otherwise, Q is not redefined bythis IF clause. The variable S0 is set equal to the variable S1, thevariable Q0 is set equal to the variable Q1, and Q is redefined as beingequal to the maximum of the variable lowlevel plus one and (the minimumof highlevel minus one and the current value of Q). The variable size isthen recomputed by compressing the image file to the now defined valueof the quality level, Q. Q1 is set equal to the value of Q, and thevariable S1 retains the current value of the variable size. The logicthen proceeds to a decision step 196.

Decision step 196 determines if the current value of the variable sizeis less than the current value of minsize and if not, the logic proceedsto a decision step 198, which determines if the current value of thevariable size is greater than the variable desiredsize. If not, a step200 sets the compression level for the current image(image.compresionlevel) equal to the current value of the variable Q,and the compressed size of the current image (image.compressedsize)equal to the current value of the variable size. This procedure is thenconcluded for the current image file, again causing the logic to returnto step 162 in FIG. 5.

If decision step 196 returns an affirmative response, a decision step202 determines if the current value of Q is greater than or equal to thevariable highlevel. If so, the logic proceeds again to step 200,.so thatthe current value of the quality level Q and the current value of thevariable size can be recorded for the current image. Essentially,decision steps 196 and 202 will have at this point determined that thecompressed size of the image file for the quality level that iscurrently being considered, Q, makes the image file too small, since itis less than the variable minsize, but also, the quality level is abovethe highest quality level desired (the variable highlevel), so there isno point in proceeding any further in the iteration. If the result indecision step 202 is negative, the logic proceeds to a step 204, whichsets the variable lowlevel equal to the current variable Q. The logicthen proceeds to a decision step 206, which determines if the variablelowlevel is equal to the value of the variable highlevel minus one andif so, proceeds to a step 208, which sets the quality level orcompression level for the image file currently being evaluated equal tothe variable lowlevel and determines the actual size of the compressedimage file (image.compressedsize) when compressed to the quality levelcorresponding to the variable lowlevel. Following step 208, the logicagain is concluded for this part of the process and return to step 162in FIG. 5.

Referring back to FIG. 6C, if the result in decision step 198 isaffirmative, the logic continues with a decision step 210 thatdetermines if the current value of Q is less than or equal to thevariable lowlevel. If so, the logic again proceeds to step 200, however,if not, the logic continues with a step 212 in which the variablehighlevel is set equal to the current value of the quality level Q.Following step 212, the logic again proceeds with decision step 206. Ifthe response to the decision step 206 is negative, the logic returns tostep 194. In regard to decision steps 198 and 210, an affirmativeresponse to each indicates that the current value of Q provides acompressed file that is greater in size than desired, but since Q isalready less than the lowest quality level deemed acceptable, there isno reason to try to make Q any lower, and thus, the logic terminates.The optimum quality level then uses the current value of Q in step 200.While it may appear that having a compressed file that is greater thanthe desiredsize would cause a problem, the next image file will simplyneed to be compressed to a slightly-smaller size than would otherwisehave been desired. It might be noted that, if the current image filebeing evaluated to determine its optimal quality level is the last inthe set of image files, a problem might occur. In fact, this problemdoes not arise, because the files that are suitable to be compressed tothe predefined minimum acceptable quality level have already beendetermined in the procedure illustrated in FIG. 4.

Once each of the image files that are not to be compressed to thepredefined minimum acceptable quality level have been processed todetermine their optimal quality level for compression, all of the imagefiles are then compressed to the quality level that was determined to beappropriate for them. As a result, the total size of all of thecompressed image files should be less than the storage capacity or lessthan the predetermined limit that was previously defined and, given thatrequirement, the quality of the files when decompressed and displayedwill be near the optimal that could be expected.

Although the present invention has been described in connection with thepreferred form of practicing it and modifications thereto, those ofordinary skill in the art will understand that many other modificationscan be made to the present invention within the scope of the claims thatfollow. Accordingly, it is not intended that the scope of the inventionin any way be limited by the above description, but instead bedetermined entirely by reference to the claims that follow.

1. A method, comprising: determining, by at least one computing deviceincluding at least one processor, an unused amount of a target set sizefor a set of media files; computing a target size range for a media fileof the set of media files based at least on the determined unused amountof the target set size of the set of media files and a measure ofcomplexity of the media file; computing a compression quality for themedia file based at least on the computed target size range; reducingthe determined unused amount of the target set size by a size computedfor the media file, wherein the computed size is based on the computedcompression quality for the media file; and repeating, by the employedat least one processor, the acts of determining the unused amount,computing the target size range, computing the compression quality, andreducing the unused amount for each of other media files in the set ofmedia files for which compression quality has not been computed.
 2. Themethod of claim 1, further comprising: compressing at least one mediafile of the set of media files using the compression quality computedfor the at least one media file.
 3. The method of claim 1, wherein themeasure of complexity is based on energies of frequencies of the mediafile.
 4. The method of claim 1, wherein the measure of complexity isbased on a quantity of pixels in the media file.
 5. The method of claim1, wherein the unused amount of the target set size is an unused amountof storage space of a storage device for storing the set of media files.6. The method of claim 1, wherein the unused amount of the target setsize is an unused amount of storage space of a remote storage device forstoring the set of media files.
 7. The method of claim 1, wherein atleast two media files from the set of media files have differentcompression quality computed.
 8. A non-transitory computer-readablemedium having stored thereon, computer-executable instructions that, inresponse to execution of at least one processor, cause a computingdevice to perform operations, comprising: determining an unused portionof a target set size for a set of media files; computing a target sizerange of a media file of the set of media files based at least on thedetermined unused portion and a measure of complexity of the media file;computing a compression quality for the media file based at least on thecomputed target size range; reducing the determined unused portion ofthe target size by a size computed for the media file, wherein thecomputed size is based on the computed compression quality for the mediafile; and repeating the determining the unused portion, the computingthe target size range, the computing the compression quality and thereducing the unused portion for each of other media files in the set ofmedia files for which compression quality has not been computed.
 9. Thenon-transitory computer-readable medium according to claim 8, theoperations further comprising: compressing at least one media file usingthe compression quality computed for the at least one media file. 10.The non-transitory computer-readable medium of claim 8, wherein themeasure of complexity is based on energies of frequencies of the mediafile.
 11. The non-transitory computer-readable medium of claim 8,wherein the measure of complexity is based on a quantity of pixels inthe media file.
 12. The non-transitory computer-readable medium of claim6, wherein the unused amount of the target set size is an unused amountof storage space of a storage device for storing the set of media files.13. The non-transitory computer-readable medium of claim 6, wherein theunused amount of the target set size is an unused amount of storagespace of a remote storage device for storing the set of media files. 14.The non-transitory computer-readable medium of claim 6, wherein at leasttwo media files from the set of media files have different compressionquality computed.
 15. A computing device including at least oneprocessor, comprising: at least one compression component configured to:determine an unused amount of a target set size for a set of mediafiles; compute a target size range for a media file of the set of mediafiles based at least on the determined unused amount of the target setsize and a measure of complexity of the media file; compute acompression quality for the image based at least on the computed targetsize range; and reduce the determined unused amount of the target sizeby a size computed for the media file, wherein the computed size isbased on the computed compression quality for the media file; repeat thedetermine the unused amount, the compute the target size range, thecompute the compression quality, and the reduce the unused amount foreach of other media files in the set of media files for whichcompression quality has not been computed.
 16. The computing device ofclaim 15, wherein the at least one compression component is furtherconfigured to compress at least one media file using the compressionquality computed for the at least one media file.
 17. The computingdevice of claim 15, wherein the measure of complexity is based onenergies of frequencies of the media file.
 18. The computing device ofclaim 15, wherein the measure of complexity is based on a quantity ofpixels in the media file.
 19. The computing device of claim 15, whereinthe unused amount of the target set size is an unused amount of storagespace of a storage device.
 20. The computing device of claim 15, whereinthe unused amount of the target set size is an unused amount of storagespace of a remote storage device.
 21. The computing device of claim 15,wherein at least two media files from the set of media files havedifferent compression quality computed. 1